#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
 
long long mul(int s,int e,int s2,int e2)
{
    long long res = 1;
    while(s<=e)
    {
        res = (res* s)/s2;
        s++;
        s2++;
    }
    return res;
}
 
int main()
{
    int cases;
    scanf("%d",&cases);
    int n,k;
    long long sol;
    while(cases--)
    {
        scanf("%d %d",&n,&k);
        n--;k--;
        sol = 1;
        if(n-k > k)
            printf("%lld\n",mul(n-k+1,n,1,k));
        else
            printf("%lld\n",mul(k+1,n,1,n-k));
    }
    return 0;
} 
 
